package ace.cmp.util;

import com.google.common.base.CaseFormat;

/**
 * @author caspar
 * @date 2023/9/19 16:49
 */
public final class CaseFormatUtils {

  public static String convertClassFullNameUpperCamelToLowerUnderscore(Class cls) {
    return cls.getPackageName().replaceAll("\\.", "_")
        + "_"
        + CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, cls.getSimpleName());
  }

  public static String convertUpperCamelToLowerDash(String value) {
    return convertUpperCamelToLowerUnderscore(value).replaceAll("_", "-");
  }

  public static String convertUpperCamelToLowerUnderscore(String value) {
    return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, value);
  }

  public static String convertLowerCamelToUpperUnderscore(String value) {
    return CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, value);
  }

  public static String convertLowerCamelToLowerUnderscore(String value) {
    return CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, value);
  }

}
